/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.controller;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
import queenb.net.entitybean.N100;
import queenb.web.controller.user.B670Controller;
import queenb.web.controller.user.GroupController;
import queenb.web.controller.user.K250Controller;
import queenb.web.controller.user.N550Controller;
import queenb.web.crm.controller.V030controller;
import queenb.web.crm.store.*;
import queenb.web.permission.controller.Q350Controller;
import queenb.web.permission.store.B050Store;
import queenb.web.permission.store.Q400Store;
import queenb.web.product.store.S100Store;
import queenb.web.product.store.S400Store;
import queenb.web.store.*;
import queenb.web.supplier.store.T025Store;
import queenb.web.supplier.store.V220Store;
import queenb.web.util.SessionProvider;
import queenb.web.util.Util;

/**
 *
 * @author em
 */
public class DeleteController extends QueenbController {

    private static Logger logger = Logger.getLogger(DeleteController.class);

    /**
     * @return the logger
     */
    public static Logger getLogger() {
        return logger;
    }

    /**
     * @param aLogger the logger to set
     */
    public static void setLogger(Logger aLogger) {
        logger = aLogger;
    }
    private int primarykey;
    private int foreignkey;
    private String table;
    private int pn100C;
    private String table1;
    private String pagereload;
    private EmployeeController employeeController;
    private N950Controller n950Controller;
    private N350Controller n350Controller;
    private L200Controller l200Controller;
    private GroupController groupController;
    private N550Controller n550Controller;
    private K250Controller k250Controller;
    private Q350Controller q350Controller;
    private B670Controller b670Controller;
    private boolean flagabc;
    private String fc150;
    private String emp;
    private String stringtab;
    
   // private int 
    public DeleteController() {
        super();
        try {
            Object pi = getRequest().getParameter("p");
            //   System.out.println("SSSSSSSSSSSSSSSSSSSSSSSSSSS" + pi);
            if (pi != null) {
                this.flagabc = true;
            }
        } catch (Exception e) {
        }
        Object id = getRequest().getParameter("id");
        Object objforeignkey = getRequest().getParameter("id2");
        Object flag = getRequest().getParameter("flag");
        Object pn100 = getRequest().getParameter("pn100C");
        Object tableObject = getRequest().getParameter("table1");
        Object page = getRequest().getParameter("page");
        Object objEmp = getRequest().getParameter("emp");
        Object stringTab =  getRequest().getParameter("tab");
        if (stringTab != null) {
            stringtab = stringTab.toString();
        }
        if (objforeignkey != null) {
            foreignkey = Integer.parseInt(objforeignkey.toString());
        }
        Object objAction = getRequest().getParameter("actionDel");
        if (objAction != null) {
            String action = objAction.toString();
            if (action.equals("deleteC150")) {
                Object objFc150 = getRequest().getParameter("fc150");
                if (objFc150 != null) {
                    fc150 = objFc150.toString();
                    //       System.out.println("fc150---:" + fc150);
                }
                if (flag != null) {
                    table = flag.toString();
                    //      System.out.println("table --:" + table);
                }
                if (objEmp != null) {
                    emp = objEmp.toString();
                    //    System.out.println("emp---:" + emp);
                }
            }
        } else if (id != null && flag != null) {
            if (pn100 == null) {
                primarykey = Integer.parseInt(id.toString());
                table = flag.toString();
                try {
                    if (table1 == null) {
                        this.table1 = tableObject.toString();
                    }
                } catch (Exception ex) {
                }
                try {
                    if (page != null) {
                        this.pagereload = page.toString();
                    }
                } catch (Exception e) {
                }
            } else {
                primarykey = Integer.parseInt(id.toString());
                table = flag.toString();
                pn100C = Integer.parseInt(pn100.toString());
                try {
                    if (table1 == null) {
                        this.table1 = tableObject.toString();
                    }
                } catch (Exception ex) {
                }
                if (page != null) {
                    this.pagereload = page.toString();
                }
            }
        }
        
    }
    
    public void deleteemail(){
        
    }
    public void deleteV180() {
        V180Store store = new V180Store();
        try {
            System.out.println("----->" + primarykey + "======" + foreignkey);
            int count = store.stdv_tools_stornotabv180(primarykey,foreignkey, getLogin().getUserName());
            if (count > 0) {
                showGlobalReport(true, getResourceString("datasavesuccessful"));

            } else {
                showGlobalReport(true, getResourceString("datasuccessfail"));
            }
            V030controller v030 = new V030controller();
           sendRedirectUrlTab("customer4tour.jsp?status=T&pv050=" + v030.getFV050() + "&action=delSS&tab=upheader" + primarykey);

        } catch (Exception e) {
        }

    }
    // xao tin nhan
    public void deleteM020() {
        M020Store store = new M020Store();
        try {
            System.out.println("----->" + primarykey + "======" + foreignkey);
            int count = store.stdm_tools_stornotabm020(primarykey, getLogin().getUserName());
            if (count > 0) {
                showGlobalReport(true, getResourceString("datasavesuccessful"));

            } else {
                showGlobalReport(true, getResourceString("datasuccessfail"));
            }
           
           sendRedirectUrlTab("historySMS.jsp");

        } catch (Exception e) {
        }

    }
    // chuyen nhân vien qua kahch hngaf
    public void updateEmptoCus() {
        try {
            EmployeeStore employeeStore = new EmployeeStore();

            if (SessionProvider.getSessionMapValue("empConvert") != null) {
                table1 = SessionProvider.getSessionMapValue("empConvert").toString();
            }

            //    System.out.println("---------- DELETE DD------"+ primarykey+ table1);
            int count = employeeStore.convertEmtoCus(primarykey, table1, getLogin().getUserName());
            // System.out.println("---------- DELETE DD---DDDDDDDDDDDĐ---"+ count);
            if (count > 0) {
                // long lDateTime1 = new Date().getTime();
                sendRedirectUrlTab("employeenew.jsp");
                showGlobalReport(true, getResourceString("datasavesuccessful"));
            } else {
                sendRedirectUrlTab("employeenew.jsp");
                showGlobalReport(true, getResourceString("datasuccessfail"));
            }
        } catch (Exception e) {
        }
    }

    public void deleteN450() {
        N450Store store = new N450Store();
        int countN350i = store.deleteN450(primarykey, getLogin().getUserName());
        if (countN350i > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("setting.jsp?tab=header14&link14=" + Util.convertMD5(getRequest().getRequestURI()));


    }

    public void updateDDtoNV() {
        try {
            CustomerStore customerStore = new CustomerStore();
            //   System.out.println("---------- DELETE DD------"+ primarykey);
            int count = customerStore.updateColumnN100(null, "N100", "NN117", String.valueOf(1), "PN100", primarykey, getLogin().getUserName());
            //  System.out.println("---------- DELETE DD------"+ count);
            if (count > 0) {
                long lDateTime1 = new Date().getTime();
              //  sendRedirectUrlTab("cuscompany.jsp?action=linkCom&pnPK100=" + pn100C + "&tab=tab3" + pn100C + "&flag=" + lDateTime1 + "&#" + pn100C + "");
                showGlobalReport(true, getResourceString("datasavesuccessful"));
                sendRedirectURLnew("cuscompany.jsp", "itemcontent", pn100C);
            } else {
                long lDateTime1 = new Date().getTime();
              //  sendRedirectUrlTab("cuscompany.jsp?action=linkCom&pnPK100=" + pn100C + "&tab=tab3" + pn100C + "&flag=" + lDateTime1 + "&#" + pn100C + "");
                showGlobalReport(true, getResourceString("datasuccessfail"));
                sendRedirectURLnew("cuscompany.jsp", "itemcontent", pn100C);
            }
        } catch (Exception e) {
        }
    }
    // xóa nhân viên ra khỏi công ty

    public void updateDDtoNV1() {
        try {
            CustomerStore customerStore = new CustomerStore();
            //   System.out.println("---------- DELETE DD------"+ primarykey);
            int count = customerStore.updateColumnN100(null, "N100", "FK100", String.valueOf(442), "PN100", primarykey, getLogin().getUserName());
            int count1 = customerStore.updateColumnN100(null, "N100", "KV103", "", "PN100", primarykey, getLogin().getUserName());
            int count2 = customerStore.updateColumnN100(null, "N100r", "FK100", String.valueOf(442), "PN100", primarykey, getLogin().getUserName());
            int count3 = customerStore.updateColumnN100(null, "N100r", "KV103", "", "PN100", primarykey, getLogin().getUserName());
            // System.out.println("---------- DELETE DD------"+ count);
            if (count > 0 && count1 > 0 && count2 > 0 && count3 > 0) {
                long lDateTime1 = new Date().getTime();
               // sendRedirectUrlTab("cuscompany.jsp?action=linkCom&pnPK100=" + pn100C + "&tab=tab2" + pn100C + "&flag=" + lDateTime1 + "&#" + pn100C + "");
                showGlobalReport(true, getResourceString("datasavesuccessful"));
                sendRedirectURLnew("cuscompany.jsp", "itemcontent", pn100C);
            } else {
                long lDateTime1 = new Date().getTime();
              //  sendRedirectUrlTab("cuscompany.jsp?action=linkCom&pnPK100=" + pn100C + "&tab=tab2" + pn100C + "&flag=" + lDateTime1 + "&#" + pn100C + "");
                showGlobalReport(true, getResourceString("datasuccessfail"));
                 sendRedirectURLnew("cuscompany.jsp", "itemcontent", pn100C);
            }
        } catch (Exception e) {
        }
    }

    public void deleteV020() {
        V020Store store = new V020Store();
        int rs = store.deleteV020(primarykey, getLogin().getUserName());
        if (rs > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("listTour.jsp?action=showmenupersonal&FV050=" + foreignkey);


    }

    public void deleteB650() {
        B630Store store = new B630Store();
        int rs = store.STORNOTABB650(primarykey, foreignkey, getLogin().getUserName());
        if (rs > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab(pagereload + Util.convertMD5(getRequest().getRequestURI()));


    }

    public void deleteK300() {
        K300Store store = new K300Store();
        int countN350i = store.deleteK300(primarykey, getLogin().getUserName());
        if (countN350i > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("setting.jsp?tab=header19&link19=" + Util.convertMD5(getRequest().getRequestURI()));


    }

    public void deleteK330() {
        K330Store store = new K330Store();
        int countN350i = store.deleteK330(primarykey, getLogin().getUserName());
        if (countN350i > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("setting.jsp?tab=header20&link20=" + Util.convertMD5(getRequest().getRequestURI()));


    }

    public void deleteA000() {
        A000Store store = new A000Store();
        int countN350i = store.deleteA000(primarykey, getLogin().getUserName());
        if (countN350i > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("setting.jsp?tab=header18&link21=" + Util.convertMD5(getRequest().getRequestURI()));


    }

    public void deleteC050() {
        C050Store store = new C050Store();
        int countN350i = store.deleteC050(primarykey, getLogin().getUserName());
        if (countN350i > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("setting.jsp?tab=header13&link13=" + Util.convertMD5(getRequest().getRequestURI()));


    }

    public void deleteN000() {
        N000Store store = new N000Store();
        int countN350i = store.deleteN000(primarykey, getLogin().getUserName());
        if (countN350i > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("setting.jsp?tab=header12&link12=" + Util.convertMD5(getRequest().getRequestURI()));


    }

    public void deleteV220() {
        V220Store store = new V220Store();
        int countN350i = store.deleteV220(primarykey, getLogin().getUserName());
        if (countN350i > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectURL(pagereload, pn100C, 9);


    }

    public void deleteN250() {
        N250Store store = new N250Store();
        int countN350i = store.deleteN250(primarykey, getLogin().getUserName());
        if (countN350i > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("setting.jsp?tab=header15&link15=" + Util.convertMD5(getRequest().getRequestURI()));


    }

    public void deleteQ000() {
        Q000Store store = new Q000Store();
        int count = store.deleteQ000(primarykey, getLogin().getUserName());
        if (count > 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));
        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        sendRedirectUrlTab("myprofile.jsp?fn100M=" + getLogin().getId() + "&linkfref=" + Util.convertMD5(getRequest().getRequestURI()));
    }

    public void deleteF000() {
        F000Store store = new F000Store();
        int countN350i = store.deleteF000(primarykey, getLogin().getUserName());
        if (countN350i > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("setting.jsp?tab=header21&link21=" + Util.convertMD5(getRequest().getRequestURI()));


    }

    public void deleteN500() {
        N500Store store = new N500Store();
        try {
            System.out.println("----->" + primarykey + "======" + pn100C);
            int count = store.deleteN500(pn100C, primarykey, getLogin().getUserName());
            if (count > 0) {
                showGlobalReport(true, getResourceString("datasavesuccessful"));

            } else {
                showGlobalReport(true, getResourceString("datasuccessfail"));
            }
            if (table.equals("N500N")) {
                sendRedirect("detailCalender.jsp");
            } else {
                sendRedirect("employeeCalender.jsp");
            }

        } catch (Exception e) {
        }

    }

    public void deleteT025() {
        T025Store store = new T025Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteT025(pn100C, primarykey, table1, getLogin().getUserName());
        } catch (Exception e) {
        }

        if (count > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));


        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
if(pagereload!=null){
     sendRedirectURLnew(pagereload, stringtab, primarykey);
}
//        if (pagereload.equals("employee.jsp")) {
//            sendRedirectURL(pagereload, primarykey, 5);
//        } else if (pagereload.equals("supplier.jsp")) {
//            sendRedirectURL(pagereload, primarykey, 5);
//        } else if (pagereload.equals("customer.jsp")) {
//          //  sendRedirectURL(pagereload, primarykey, 7);
//             sendRedirectURLnew(pagereload, stringtab, primarykey);
//        } else if (pagereload.equals("cuscompany.jsp")) {
//            sendRedirectURL(pagereload, primarykey, 8);
//        } else if (pagereload.equals("partner.jsp")) {
//            sendRedirectURL(pagereload, primarykey, 5);
//        } else if (pagereload.equals("employeenew.jsp")) {
//           // sendRedirectURL(pagereload, primarykey, 5);
//            sendRedirectURLnew(pagereload, stringtab, primarykey);
//        }
    }

    public void deleteB0501() {
        B050Store store = new B050Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.delete(primarykey, getLogin().getUserName());
        } catch (Exception e) {
        }

        if (count > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));


        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirect("project.jsp");
    }

    public void deleteV200() {
        V200Store store = new V200Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteV200(primarykey, getLogin().getUserName());
        } catch (Exception e) {
        }

        if (count > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));


        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("setting.jsp?tab=header5&link5=" + Util.convertMD5(getRequest().getRequestURI()));
    }

    public void deleteS200() {
        S200Store store = new S200Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteV200(primarykey, getLogin().getUserName());
        } catch (Exception e) {
        }

        if (count > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));


        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
//        if (table1.equals("MT")) {
//            sendRedirect("setting.jsp?tab=header6");
//        } else if (table1.equals("MW")) {
//            sendRedirect("setting.jsp?tab=header7");
//        }
        sendRedirectUrlTab("setting.jsp?tab=header7&link17=" + Util.convertMD5(getRequest().getRequestURI()));
    }

    public void deleteS250() {
        S250Store store = new S250Store();
        try {
            System.out.println("----->" + primarykey);
            int count = store.delete(primarykey, getLogin().getUserName());
            if (count > 0) {
                showGlobalReport(true, getResourceString("datasuccessfail"));
            } else {
                showGlobalReport(true, getResourceString("datasavesuccessful"));
            }
        } catch (Exception e) {
        }

        sendRedirectUrlTab("setting.jsp?tab=header8&link18=" + Util.convertMD5(getRequest().getRequestURI()));

    }

    public void deleteB050() {
        B050Store store = new B050Store();
        try {
            System.out.println("----->" + primarykey);
            int count = store.delete(primarykey, getLogin().getUserName());
            if (count > 0) {
                showGlobalReport(true, getResourceString("datasavesuccessful"));
            } else {
                showGlobalReport(true, getResourceString("datasuccessfail"));
            }
        } catch (Exception e) {
        }

        sendRedirectUrlTab("setting.jsp?tab=header9&link9=" + Util.convertMD5(getRequest().getRequestURI()));

    }

    public void deleteQ350() {
        q350Controller = new Q350Controller();
        int count = q350Controller.deleteQ350(primarykey);
        if (count > 0) {
            sendRedirect("Q350.jsp");
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
    }

    public void deleteN850() {
        groupController = new GroupController();
        int count = groupController.deleteN850(primarykey);
        if (count > 0) {
            sendRedirectUrlTab("setting.jsp?tab=header1&lilnk1=" + Util.convertMD5(getRequest().getRequestURI()));
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
    }

    public void deleteK250() {
        k250Controller = new K250Controller();
        int count = k250Controller.deleteK250(primarykey);
        if (count > 0) {
            sendRedirectUrlTab("setting.jsp?tab=header3&link3=" + Util.convertMD5(getRequest().getRequestURI()));
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
    }

    public void deleteB670() {
        b670Controller = new B670Controller();
        int count = b670Controller.deleteB670(primarykey);
        if (count > 0) {
            sendRedirectUrlTab("setting.jsp?tab=header4&link4=" + Util.convertMD5(getRequest().getRequestURI()));
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
    }

    public void deleteN550() {
        n550Controller = new N550Controller();
        int count = n550Controller.deleteN550(primarykey);
        if (count > 0) {
            sendRedirectUrlTab("setting.jsp?tab=header2&link2=" + Util.convertMD5(getRequest().getRequestURI()));
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
    }

    public void deleteN100() {
        EmployeeStore employeeStore = new EmployeeStore();
        int count = employeeStore.deleteEmployee(primarykey, getLogin().getUserName());
        System.out.println("-------COUNT XOA NHAN VIEN---"+count);
        if (count > 0) {
            sendRedirect("employeenew.jsp");
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            sendRedirect("employeenew.jsp");
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

    }

    public void deleteN100C() throws SQLException, InstantiationException, IllegalAccessException {
        employeeController = new EmployeeController();
        int count = employeeController.deleteEmployee(primarykey);
        if (count > 0) {
            sendRedirectURL("cuscompany.jsp", pn100C, 3);
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }


    }

    public void deleteN100D() throws SQLException, InstantiationException, IllegalAccessException {
        employeeController = new EmployeeController();
        int count = employeeController.deleteEmployee(primarykey);
        if (count > 0) {
            sendRedirectURL("cuscompany.jsp", pn100C, 2);
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }


    }

    public void deleteN950() {
        n950Controller = new N950Controller();
        int countN950 = n950Controller.deleteN950(pn100C, primarykey);
        if (countN950 > 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        if (table1.equals("myprofile")) {
            sendRedirectUrlTab("myprofile.jsp?fn100M=" + pn100C + "&linkmyprofile=" + Util.convertMD5(getRequest().getRequestURI()));
        } else {
          //  sendRedirectURL(pagereload, pn100C, 1);
            System.out.println("----------TAB NEW N950--------"+pagereload+stringtab+pn100C);
            sendRedirectURLnew(pagereload,stringtab,pn100C);
        }

    }

    public void deleteK950() {
        K950Store store = new K950Store();

        int countN950 = store.deleteK950(pn100C, primarykey, "K100", getLogin().getUserName());
        if (countN950 > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        System.out.println("----------TAB NEW N950--------"+pagereload+stringtab+pn100C);
        if(pagereload!=null){
            sendRedirectURLnew(pagereload,stringtab,pn100C);
        }
//        if (pagereload.equals("cuscompany.jsp")) {
//             sendRedirectURLnew(pagereload,stringtab,pn100C);
//           // sendRedirectURL("cuscompany.jsp", pn100C, 1);
//        } else if (pagereload.equals("partner.jsp")) {
//            sendRedirectURL("partner.jsp", pn100C, 1);
//        } else if (pagereload.equals("supplier.jsp")) {
//            sendRedirectURL("supplier.jsp", pn100C, 1);
//        }

    }

    public void deleteM650() {
        M650Store store = new M650Store();
        int count = 0;
        try {
            count = store.deleteM650(primarykey, getLogin().getUserName());
        } catch (Exception e) {
        }

        if (count > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        if (pagereload.equals("supplier.jsp")) {
            sendRedirectURL(pagereload, pn100C, 3);
        } else if (pagereload.equals("employee.jsp")) {
            sendRedirectURL(pagereload, pn100C, 4);
        } else if (pagereload.equals("cuscompany.jsp")) {
           // sendRedirectURL(pagereload, pn100C, 4);
            sendRedirectURLnew(pagereload, stringtab, pn100C);
        } else if (pagereload.equals("customer.jsp")) {
            sendRedirectURLnew(pagereload, stringtab, pn100C);
           // sendRedirectURL("customer.jsp", pn100C, 6);
        } else if (pagereload.equals("documentTour.jsp")) {
            sendRedirect("documentTour.jsp?tab=item_head_care" + pn100C);
        } else if (pagereload.equals("documentmanager.jsp")) {
            sendRedirect("documentmanager.jsp");
        } else if (pagereload.equals("partner.jsp")) {
            sendRedirectURL(pagereload, pn100C, 3);
        }else if (pagereload.equals("employeenew.jsp")) {
         //   sendRedirectURL(pagereload, pn100C, 3);
            sendRedirectURLnew(pagereload, stringtab, pn100C);
        }


    }

    public void deleteK100Su() {
        K100Store store = new K100Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteK100(primarykey, getLogin().getUserName());
        } catch (Exception e) {
        }

        if (count > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));


        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        sendRedirect("supplier.jsp");
        // System.out.println("----->reloadddddddddddddddddd" + pn100);



    }

    public void deleteK100() {
        K100Store store = new K100Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteK100(primarykey, getLogin().getUserName());
        } catch (Exception e) {
        }

        if (count > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));


        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        sendRedirect("cuscompany.jsp");
        // System.out.println("----->reloadddddddddddddddddd" + pn100);



    }

    public void deleteK100S() {
        K100Store store = new K100Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey + pagereload);
            count = store.deleteK100(primarykey, getLogin().getUserName());
        } catch (Exception e) {
        }

        if (count >= 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));


        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        if (pagereload.equals("supplier.jsp")) {
            sendRedirect("supplier.jsp");
        } else {
            sendRedirect("partner.jsp");
        }

        // System.out.println("----->reloadddddddddddddddddd" + pn100);



    }

    public void deleteK100K() throws SQLException, InstantiationException, IllegalAccessException {
        employeeController = new EmployeeController();
        int count = employeeController.deleteEmployee(primarykey);
        if (count > 0) {
            sendRedirectURL("supplier.jsp", pn100C, 2);
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }


    }

    public void deleteN9502() {
        System.out.println("---->+day la ham delete N900" + table);

    }

    public void deleteN350() {
        n350Controller = new N350Controller();
        int countN350 = n350Controller.deleteN350(primarykey);
        if (countN350 > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        if (table1.equals("myprofile")) {
            sendRedirectUrlTab("myprofile.jsp?fn100M=" + pn100C + "&linkfn100=" + Util.convertMD5(getRequest().getRequestURI()));
        } else {
           // sendRedirectURL(pagereload, pn100C, 3);
            sendRedirectURLnew(pagereload, stringtab, pn100C);
        }

    }

    public void deleteL200() {
        l200Controller = new L200Controller();
        try {
            int countL200 = l200Controller.deleteL200(primarykey);
            //sendRedirectURL("employee.jsp", primarykey, 2);
            System.out.println("-----------------"+pagereload+ stringtab+ primarykey);
            sendRedirectURLnew(pagereload, stringtab, primarykey);
            showGlobalReport(true, getResourceString("datasavesuccessful"));
        } catch (Exception ex) {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

    }

    public void deleteQ400() {
        Q400Store store = new Q400Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteQ400(primarykey, getLogin().getUserName());
        } catch (Exception e) {
        }

        if (count > 0) {

            showGlobalReport(true, getResourceString("datasavesuccessful"));


        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        sendRedirectUrlTab("q300.jsp?fq300=" + pn100C + "&linkq300=" + Util.convertMD5(getRequest().getRequestURI()));

    }

    public void deleteK400() {
        K400Store store = new K400Store();
        int count = 0;
        if (SessionProvider.getSessionMapValue("groupcustomerID") != null) {
            primarykey = Integer.parseInt(SessionProvider.getSessionMapValue("groupcustomerID").toString());
        }
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteK400(primarykey, getLogin().getUserName());
        } catch (Exception e) {
        }

        if (count > 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));
            SessionProvider.setSessionMapValue("groupcustomerID", 0);

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        sendRedirect("customer.jsp");

    }

    public void deleteV030() {
        V030Store store = new V030Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteV030(pn100C, primarykey, getLogin().getUserName());
        } catch (Exception e) {
        }

        if (count > 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        sendRedirect("customer4tour.jsp");

    }

    public void deleteC150() {
        C150Store store = new C150Store();
        int count = 0;
        try {
            System.out.println("---fc150-->" + fc150);
            count = store.StornoTab150(fc150, getLogin().getUserName());
            System.out.println("----->count >>>>" + count);
        } catch (Exception e) {
        }

        if (count > 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        System.out.println("----->emp >>>>" + emp);
        sendRedirectUrlTab("project.jsp?emp=" + emp + "&linkproject=" + Util.convertMD5(getRequest().getRequestURI()));


    }

    public void deleteV050() {
        V050Store store = new V050Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteV050(primarykey, getLogin().getUserName());
            System.out.println("----->count >>>>" + count);
        } catch (Exception e) {
        }

        if (count >= 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        if (flagabc == true) {
            sendRedirect("managerSale.jsp");
        } else {
            sendRedirectUrlTab("setting.jsp?tab=header6&link6=" + Util.convertMD5(getRequest().getRequestURI()));
        }

    }

    public void deleteV050D() {
        V050Store store = new V050Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteV050(primarykey, getLogin().getUserName());
            System.out.println("----->count >>>>" + count);
        } catch (Exception e) {
        }

        if (count >= 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        if (flagabc == true) {
            sendRedirect("listTour.jsp");
        } else {
            sendRedirect("listTour.jsp");
        }

    }

    public void deleteV050FF() {
        V050Store store = new V050Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteV050(primarykey, getLogin().getUserName());
            System.out.println("----->count >>>>" + count);
        } catch (Exception e) {
        }

        if (count >= 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));
            sendRedirectUrlTab("codeproductTour.jsp?action=detailTour&FS400=" + foreignkey);

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }


    }

    public void deleteM200() {
        M200Store store = new M200Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            count = store.deleteM200(getLogin().getModule(), getLogin().getCompanyNo(), primarykey, getLogin().getUserName());
            System.out.println("----->count >>>>" + count);
        } catch (Exception e) {
        }

        if (count >= 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        if (flagabc == true) {
            sendRedirectUrlTab("setting.jsp?tab=header21&lilnkM200=" + Util.convertMD5(getRequest().getRequestURI()));
        } else {
            sendRedirectUrlTab("setting.jsp?tab=header21&lilnkM200=" + Util.convertMD5(getRequest().getRequestURI()));
        }

    }

    public void deleteS100() {
        S100Store store = new S100Store();
        int count = 0;
        try {
            System.out.println("-deleteS100---->" + primarykey);
            count = store.STORNOTABS100(primarykey, getLogin().getUserName());
            System.out.println("----->count >>>>" + count);
        } catch (Exception e) {
            count = -1;
        }

        if (count > 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("createProduct.jsp?tab=s100" + foreignkey);


    }

    public void deleteS400() {
        S400Store store = new S400Store();
        int count = 0;
        try {
            System.out.println("-deleteS400---->" + primarykey);
            count = store.STORNOTABS400(primarykey, getLogin().getUserName());
            System.out.println("----->count >>>>" + count);
        } catch (Exception e) {
            count = -1;
        }

        if (count > 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

        sendRedirectUrlTab("createProduct.jsp");


    }

    public void deleteM250() {
        M250Store store = new M250Store();
        int count = 0;
        try {
            System.out.println("-deleteM250---->" + primarykey);
            count = store.deleteM250(getLogin().getModule(), getLogin().getCompanyNo(), primarykey, getLogin().getUserName());
            System.out.println("----->count >>>>" + count);
        } catch (Exception e) {
            count = -1;
        }

        if (count > 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }

       sendRedirectUrlTab("setting.jsp?tab=header111&lilnkM200=" + Util.convertMD5(getRequest().getRequestURI()));

    }

    public void deleteCus() {
        List<N100> li = new ArrayList<N100>();
        System.out.println("D:--deleteCus iss Called !");
        Object listselect = SessionProvider.getSessionMapValue("listSelected");
        if (listselect != null) {
            System.out.println("listselect != null");
        }
        System.out.println("listselect size:");
        try {
            li = (List<N100>) listselect;
        } catch (Exception e) {
            li = new ArrayList<N100>();
        }

        System.out.println("D: li: " + li.size());
        V030Store store = new V030Store();
        int count = 0;
        try {
            System.out.println("----->" + primarykey);
            for (N100 n100 : li) {
                System.out.println(n100.getFullName() + " - " + pn100C + " - " + n100.getPn100());
                int fv050_ = 0;
                Object objfv050 = SessionProvider.getSessionMapValue("codetourselect");
                if (objfv050 != null) {
                    try {
                        fv050_ = Integer.parseInt(objfv050.toString());
                    } catch (Exception e) {
                        fv050_ = 0;
                    }
                }
                System.out.println("D:-   deleteV030: " + n100.getFullName() + " - " + fv050_ + " - " + n100.getPn100());
                count = store.deleteV030(fv050_, n100.getPn100(), getLogin().getUserName());
                System.out.println("D: Count: " + count);
            }

        } catch (Exception e) {
            System.out.println("D: error: " + e.getMessage());
        }

        if (count > 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
        sendRedirect("customer4tour.jsp");

    }

    /**
     * @return the primarykey
     */
    public int getPrimarykey() {
        return primarykey;
    }

    /**
     * @param primarykey the primarykey to set
     */
    public void setPrimarykey(int primarykey) {
        this.primarykey = primarykey;
    }

    /**
     * @return the table
     */
    public String getTable() {
        return table;
    }

    /**
     * @param table the table to set
     */
    public void setTable(String table) {
        this.table = table;
    }

    /**
     * @return the pn100C
     */
    public int getPn100C() {
        return pn100C;
    }

    /**
     * @param pn100C the pn100C to set
     */
    public void setPn100C(int pn100C) {
        this.pn100C = pn100C;
    }

    /**
     * @return the table1
     */
    public String getTable1() {
        return table1;
    }

    /**
     * @param table1 the table1 to set
     */
    public void setTable1(String table1) {
        this.table1 = table1;
    }

    /**
     * @return the pagereload
     */
    public String getPagereload() {
        return pagereload;
    }

    /**
     * @param pagereload the pagereload to set
     */
    public void setPagereload(String pagereload) {
        this.pagereload = pagereload;
    }

    /**
     * @return the flagabc
     */
    public boolean isFlagabc() {
        return flagabc;
    }

    /**
     * @param flagabc the flagabc to set
     */
    public void setFlagabc(boolean flagabc) {
        this.flagabc = flagabc;
    }

    /**
     * @return the fc150
     */
    public String getFc150() {
        return fc150;
    }

    /**
     * @param fc150 the fc150 to set
     */
    public void setFc150(String fc150) {
        this.fc150 = fc150;
    }

    /**
     * @return the emp
     */
    public String getEmp() {
        return emp;
    }

    /**
     * @param emp the emp to set
     */
    public void setEmp(String emp) {
        this.emp = emp;
    }

    /**
     * @return the foreignkey
     */
    public int getForeignkey() {
        return foreignkey;
    }

    /**
     * @param foreignkey the foreignkey to set
     */
    public void setForeignkey(int foreignkey) {
        this.foreignkey = foreignkey;
    }

    /**
     * @return the stringtab
     */
    public String getStringtab() {
        return stringtab;
    }

    /**
     * @param stringtab the stringtab to set
     */
    public void setStringtab(String stringtab) {
        this.stringtab = stringtab;
    }
    
}
